package com.clothe.action;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.clothe.dto.Kind;
import com.clothe.service.KindService;

/**
 * Servlet implementation class KindAction
 */
public class KindAction extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public KindAction() {
        super();
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
			doPost(request,response);
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		if(request.getParameter("oper").equals("list"))
			list(request,response);
			
	}

	public void list(HttpServletRequest request, HttpServletResponse response) {
		KindService infoService = null;
		List<Kind> kindlist = null;
		try {
			infoService = new KindService();
			kindlist = new ArrayList<Kind>();
			kindlist = infoService.list();
			request.setAttribute("kindlist",kindlist);
			request.getRequestDispatcher("/admin/clothingmanage/clothingsave.jsp").forward(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
	}

}
